<template>
    <a-modal v-model:open="visible" title="重置密码" :destroy-on-close="destroyOnClose" width="480px" :mask-closable="maskClosable" @ok="handleSubmit">
        <Form ref="formRef" />
    </a-modal>
</template>
<script setup>
import { nextTick, ref } from 'vue'
import { useModal } from '@iframe/tools/mixins/ModelDrawerMixins'
import { resetPass } from '/@/api/System/User'
import Form from './Form.vue'

const { visible, destroyOnClose, maskClosable, close, submit } = useModal()
const formRef = ref()
const emits = defineEmits(['close'])
const handleSubmit = () => {
    submit({ formRef: formRef, update: resetPass }).then(() => {
        emits('close')
        close()
    })
}
const open = item => {
    visible.value = true
    nextTick().then(() => {
        formRef.value.setForm(item)
    })
}

defineExpose({ open })
</script>
